package com.company.admin.controller.people;

import com.company.admin.common.annotations.VisitAble;
import com.company.admin.common.result.ResultResponse;
import com.company.admin.req.people.ProfessionalPeopleAddRequest;
import com.company.admin.req.people.ProfessionalPeopleDeleteRequest;
import com.company.admin.req.people.ProfessionalPeopleListRequest;
import com.company.admin.req.people.ProfessionalPeopleModifyRequest;
import com.company.admin.resp.people.ProfessionalPeopleListResponse;
import com.company.admin.service.people.ProfessionalPeopleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 赵成林
 * @date 2019/2/17 19:53
 *
 * 统一使用post的方式
 * 请求参数都为json字符串
 */
@Controller
@RequestMapping("/people")
public class ProfessionalPeopleController {

    @Autowired
    private ProfessionalPeopleService professionalPeopleService;

    @ResponseBody
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ResultResponse<String> add(@RequestBody ProfessionalPeopleAddRequest professionalPeopleAddRequest){
        professionalPeopleService.add(professionalPeopleAddRequest);
        return ResultResponse.onSuccess("success", null);
    }

    @VisitAble
    @ResponseBody
    @RequestMapping(value = "/list" , method = RequestMethod.POST)
    public ResultResponse<ProfessionalPeopleListResponse> list(@RequestBody ProfessionalPeopleListRequest request){
        ProfessionalPeopleListResponse response = professionalPeopleService.list(request);
        return ResultResponse.onSuccess(response, null);
    }

    @ResponseBody
    @RequestMapping(value = "modify", method = RequestMethod.POST)
    public ResultResponse<String> modify(@RequestBody ProfessionalPeopleModifyRequest request){
        professionalPeopleService.modify(request);
        return ResultResponse.onSuccess("success", null);
    }

    @ResponseBody
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    public ResultResponse<String> delete (@RequestBody ProfessionalPeopleDeleteRequest request){
        professionalPeopleService.delete(request);
        return ResultResponse.onSuccess("success", null);
    }
}
